<template>
	<div class="box confirm-order-box" >
		<my-header :title="'确认订单'" fontColor='#FFF' backgroundColor='#38B035' :hasTitle="true" :hasBack="true" :goBack="goBack"></my-header>
		<div class="content" id="nodeBug">
			<!-- 绿色围脖 -->
			<div class="confrimOrderTopBar">

			</div>
			<div style="position:absolute;top:0;left:0;width:100%;z-index:1;">
				<!-- 地址和配送时间组件 -->
				<div class="confrimOrderTimeAddressBox">
					<div class="confrimOrderAddressBox">
						<confirm-order-address :getAddressList="userInfo" :addressItem="addressItem" :pagepath="'ConfirmOrderIntegral'"></confirm-order-address>
					</div>
					<div class="confrimOrderTimeBox">
						<confirm-getTime ref="nomalTimeshow" :data1="normalTimeList" :data2="bigTimeList" :checkedCartListNormal="checkedCartListNormal" :checkedCartListBig="checkedCartListBig" :hasBigFlag="checkedCartListBig.length >0?true:false"></confirm-getTime>
					</div>
				</div>
				<!-- 配送方式组件 -->
				<div style="width:100%;margin-top:0.75rem;">
					<confirm-send-methods></confirm-send-methods>
				</div>
				<!-- 商品列表组件 -->
				<div style="width:100%;">
					<confirm-order-list :goodsMoney="realPay" :checkedCartList="checkedCartList" :checkedCartListNormal="checkedCartListNormal" :checkedCartListBig="checkedCartListBig" :flag=true :delFlag="delFlag"></confirm-order-list>
				</div>

				<div>
					<!--信息列表-->
					<div class="aui-content aui-margin-b-15">
						<ul class="aui-list aui-list-in">
							<li class="aui-list-item">
								<div class="aui-list-item-inner">
									<div class="aui-list-item-title">商品金额</div>
									<div id="co_totalMoney" class="aui-list-item-right">¥ {{realPay.toFixed(2)}}</div>
								</div>
							</li>
							<li class="aui-list-item">
								<div class="aui-list-item-inner">
									<div class="aui-list-item-title">运费</div>
									<div id="co_totalMinis" class="aui-list-item-right">¥ {{freight.toFixed(2)}}</div>
								</div>
							</li>
						</ul>
					</div>
					<!--付款信息-->
					<div class="total_sf">
						<h2><span id="co_realpay" >实付积分：{{integralRealPay}}</span></h2>
						<p>如需发票，请到体验中心索取</p>
					</div>
				</div>
				<div id="stores_map" style="width: 0;height: 0;"></div>
			</div>
		</div>
		<!-- 底部悬浮提示 -->
		<shops-Lack :orderStatus="'integral'"></shops-Lack>
		<div class="aui-btn aui-btn-danger aui-btn-block aui-btn-sm zxSettle_acount lijixiadan" style="height: 2.5rem;line-height: 2.5rem;border-radius: 0px;padding: 0px;">
			<div style="font-size: 1rem;" @click.stop="test">提交订单</div>
		</div>
	</div>
</template>

<script>
	import MyHeader from "../header";
	import { mapGetters, mapActions, mapMutations } from "vuex";
	import { Toast } from '../../utils/toast';
	import axios from 'axios';
	import ConfirmGetTime from "../../real-components/ConfirmOrderNew/ConfirmOrderGetTime";
	import ConfirmOrderList from "../../real-components/ConfirmOrderNew/ConfirmOrderGoodsList";
	import ConfirmOrderDetail from "../../real-components/ConfirmOrderNew/ConfirmOrderDetail";
	import ConfirmSendMethods from "../../real-components/ConfirmOrderNew/ConfirmSendMethods";
	import ConfimOrderSendGift from "../../real-components/ConfirmOrderNew/ConfimOrderSendGift";
	import ConfirmOrderAddress from "../../real-components/ConfirmOrder/ConfirmOrderAddress";
	import { normal } from "../../config/orderTypeCode";
	import { MessageBox } from '../../ui-components';
	import shopsLack from "../../real-components/ConfirmOrderNew/shopsLack"; //生产
	export default {
		name: 'hello',
		data() {
			return {
				msg: '这是确认订单页面',
				page: "comfirmOrder",
				data1: [{
					text: '上午'
				}, {
					text: '就是'
				}],
				data2: [{
					text: '中午'
				}, {
					text: '不是'
				}],
				data3: [{
					text: '下午'
				}, {
					text: '是'
				}],
				//内容详情部分
				checkedCartList: [], //购物车所有商品
				checkedCartListNormal: [], //用于存放常规商品的数组
				checkedCartListBig: [], //用于存放大件商品的数组
				maxTimeNormal: [], //用于请求时间列表接口的参数
				maxTimeBig: [], //用于请求时间列表接口的参数
				normalTimeList: [], //用于接收常规商品时间列表请求结果
				bigTimeList: [], //用于接收大件商品时间列表请求结果
				shopCartIds: [], //用于下单的参数
				address: null,
				sendMoney: [],
				storeRange: null, // 配送范围
				delFlag: 0, // 用于修改样式
				clickFlag: true, // 防止两次快速点击 调用两次下单接口
				addressItem: null, //地址参数
				integralRealPay: null, //商品总积分
				realPay: 0, //商品总金额
				myPointsdata: [], //积分参数
				getNewToken: "", //防止多次点击
				flagtoken: false,
				/*supportInvoiceFlag: false,//发票*/
				//运费和金额
				goodsMoney: 0, //商品金额
				money: null, //总金额
				normalMoney: null, //常规商品金额
				bigMoney: null, //大件商品金额
				addMoney: null, //加工费用
				minNormalMoney: null, //常规最小免配送费用
				minBigMoney: null, //大件最小免配送费用
				normalM: null, //常规的运费
				bigM: null, //大件的运费
				normalMFlag: false, // 是否加运费
				bigMFlag: false, // 是否加运费
				freightM: 0, //最终运费
			}
		},
		computed: {
			...mapGetters('wxh', [
				'sessionId',
				'userInfo'
			]),
			...mapGetters('qxz', [
				"getLocation"
			]),
			...mapGetters('xxy', [
				"getconfigGoodsdata",
				'getconfigtokenNew'
			]),
			...mapGetters('zx', [
				'getAddressDetail', 'getMynode', "getTimeNormal", "getTimeBig", "getNormalM", "getBigM",
				"getDeliveryType", "getFpObj", "getTicketList", "getLadderIdList", "getGiftVOList",
				"getStoreNow", "getUseGiftCard", "getAvailAmount", "getGiftSendArr", "getToken", "getOrderFlag", "getTimeSaveObj"
			]),
			...mapGetters([
				"getConfigParams",
				"getDomTree"
			]),
			normalTime() {
				return this.normalTimeList;
			},
			bigTime() {
				return this.bigTimeList
			},
			freight() {
				return this.freightM; //运费
			},
			/*normalM() {
				if(this.getNormalM) {
					return this.getNormalM.normalM;
				}
			},*/
			/*bigM() {
				if(this.getBigM) {
					return this.getBigM.bigM;
				}
			},*/
		},
		components: {
			"MyHeader": MyHeader,
			"confirm-order-address": ConfirmOrderAddress,
			"confirm-order-detail": ConfirmOrderDetail,
			"confirm-getTime": ConfirmGetTime,
			"confirm-order-list": ConfirmOrderList,
			"confirm-send-methods": ConfirmSendMethods,
			"confim-order-send-gift": ConfimOrderSendGift,
			"shops-Lack": shopsLack,
		},
		methods: {
			...mapMutations('zx', [
				"setTimeNormal", "setTimeBig", "setFpObj", "setTicketList", "setShowMask", "setaddFlagMutation", "setToken", "setFpInfo",
				"setNowAddressMutation", "setUseGiftCard", "setMynode", "setDateNormal", "setDateBig", "setTimeSaveObj", "setOrderFlag"
			]),
			...mapMutations('cjy', [
				"changeCheckedCartList"
			]),
			...mapMutations('xxy', [
				"setconfigGoodsdata",
				'setconfigtokenNew',
				'setOrdergoback',
			]),
			//返回到详情页面
			goBack() {
				this.setOrdergoback(1)
				window.history.go(-1);
			},
			//地址参数
			getAddress() {
				if(this.$route.query.name) {
					this.addressItem = JSON.parse(this.$route.query.name);
				}
			},
			//请求商品信息
			getGoodsdata() {
				let config = {
					url: window.api.trade_host + '/integralOrder/confirmOrder',
					method: 'post',
					data: {
						integralGoodsRid: this.getconfigGoodsdata.rid,
						goodsCode: this.getconfigGoodsdata.goodscode,
						storeCode: localStorage.getItem('storeCode'),
						goodsNum: this.getconfigGoodsdata.goodsNum,
					},
					headers: {
						sessionId: localStorage.getItem('sessionId'),
					}
				};
				axios(config).then((res) => {
					if(res.data.returnCode == 3) {
						Toast({
							message: '该商品已经下架',
							duration: 2000,
							type: "fail"
						})
						setTimeout(() => {
							window.history.go(-2);
						}, 1000)
					} else if(res.data.returnCode == 2) {
						Toast({
							message: '购买该商品积分不足',
							duration: 2000,
							type: "fail"
						})
						setTimeout(() => {
							window.history.go(-2);
						}, 1000)
					} else if(res.data.returnCode == 1 && res.data.data[0]) {
						this.integralRealPay = res.data.data[0].realPay || 0
						this.realPay = res.data.data[0].totalPay || 0
						this.getNewToken = res.data.data[0].token
					}
				})
			},
			//提交订单
			test() {
				if(this.flagtoken) {
					return
				}
				this.checkStoreRange()
			},
			//判断重复进入时的路由跳转
			checkPayBack() {
				if(JSON.stringify(this.getconfigGoodsdata) == "{}" && this.getconfigtokenNew != 1) {
					this.$router.replace('profile');
					return true;
				}
				return false
			},
			//解决支付按钮不固定
			appendToPay() {
				setTimeout(() => {
					if(document.querySelector(".confirm-order-box")) {
						document.querySelector(".confirm-order-box").appendChild(document.querySelector(".zxSettle_acount"))
					}
				}, 300)
			},
			//获取最大时间
			getMaxTime(arr) {
				console.log(arr, "常规 大件”");
				if(arr.length > 0) {
					var max1 = arr[0].distributionpreparationtime;
					var max2 = arr[0].distributionprocessingtime;
					var myArr = [];
					for(let i = 0; i < arr.length; i++) {
						if(max1 < arr[i].distributionpreparationtime) {
							max1 = arr[i].distributionpreparationtime;
						}
						if(max2 < arr[i].distributionprocessingtime) {
							max2 = arr[i].distributionprocessingtime;
						}
					}
					myArr.push(max1);
					myArr.push(max2);

					return myArr;
				}
			},

			//获取初始数据
			cartList() {
				//获取所有购物车商品
				if(this.$route.query.goodsData) {
					var goodsData = {}
					goodsData = JSON.parse(this.$route.query.goodsData);
					goodsData.rid = JSON.parse(this.$route.query.rid);
					goodsData.goodsNum = JSON.parse(this.$route.query.goodsnum);
					goodsData.buyType = 4;
					goodsData.integralprice = JSON.parse(this.$route.query.integralprice);
					this.setconfigGoodsdata(goodsData)
				}
				this.checkedCartList.push(this.getconfigGoodsdata) /*this.$store.state.cjy.checkedCartList;*/
				//区分大件商品和常规商品  0 常规   1 大件
				for(var i = 0; i < this.checkedCartList.length; i++) {
					var obj = {}
					obj['rid'] = this.checkedCartList[i].rid;
					this.shopCartIds.push(obj);
					console.log(this.checkedCartList[i], this.checkedCartList[i].rid, '商品唯一标志')
					if(this.checkedCartList[i].distributiontype === 0 || this.checkedCartList[i].distributiontype === null) {
						this.checkedCartListNormal.push(this.checkedCartList[i]);
					} else if(this.checkedCartList[i].distributiontype === 1) {
						this.checkedCartListBig.push(this.checkedCartList[i]);
					}
				}
				//获取到常规和大件的加工时间 准备时间
				this.maxTimeNormal = this.getMaxTime(this.checkedCartList);
				this.maxTimeBig = this.getMaxTime(this.checkedCartListBig);
				var obj = this.getTimeSaveObj;
				let flag = this.checkObj(obj);
				if(!flag) {
					this.getTimeUserChoose();
					this.setOrderFlag(true);
				} else {
					//请求昌松的可选时间接口   获取时间列表
					if(this.checkedCartListNormal.length > 0) {
						this.getTimeList(this.maxTimeNormal, 0);
					}
					if(this.checkedCartListBig.length > 0) {
						this.getTimeList(this.maxTimeBig, 1);
					}
				}
			},
			//判断对象是否为空的方法
			checkObj(obj) {
				for(var key in obj) {
					return false;
				}
				return true;
			},
			//从vue中 获取用户已经选择了的配送时间数据
			getTimeUserChoose() {
				var obj = this.getTimeSaveObj;
				this.normalTimeList = obj.data1;
				//大件的配送时间
				this.bigTimeList = obj.data2;
				console.log(this.normalTimeList, this.bigTimeList, '大件商品常规商品哈哈哈哈哈哈哈')
			},
			//获取用户收货地址
			getToPayAddress() {
				var myAddress = this.getLocation;
				let arr = this.userInfo.addressLists;
				console.log(this.$route.query)
				var query = null;
				if(this.$route.query && this.$route.query.name) {
					query = JSON.parse(this.$route.query.name);
				}
				if(query && query.flag) {
					this.address = query;
					return true;
				} else if(myAddress && myAddress.addressid == -1) {
					var address = {
						address: myAddress.address,
						city: myAddress.city,
						defaultaddress: "1",
						label: "0",
						phone: "",
						positionlat: myAddress.positionlat,
						positionlng: myAddress.positionlng,
						province: myAddress.province,
						receivername: "",
						region: myAddress.region,
						result: "",
						sex: "0",
						houseNumber: ''
					}
					this.setaddFlagMutation(true);
					this.setNowAddressMutation(address);
					//存local 防止vuex失效  当失效时取用
					localStorage.setItem('userAddressNow', JSON.stringify(address));
					this.$router.push({
						path: 'addAddress',
						query: {
							id: 1,
							obj: JSON.stringify(address)
						}
					});
					return false;

				} else if(myAddress && myAddress.addressid != -1) {
					this.address = myAddress;
					return true;
				} else {
					return true;
				}
			},
			//获取时间列表方法
			getTimeList(data, type) {
				console.log(data, type)
				let params = {
					readyTm: data[0],
					machineTm: data[1],
					storeCode: localStorage.getItem('storeCode')
				};
				let config = {
					url: window.api.trade_host + "/delivery_config/tm_interval/" + type,
					method: 'GET',
					params,
					headers: {
						'sessionId': this.sessionId
					},
				};
				console.log(config.url)
				axios(config).then((res) => {
					console.log(res.data.data, 'shiajianliebaios', type);
					if(type === 0) {
						if(res.data.data && res.data.data.length) {
							this.normalTimeList = res.data.data;
							console.log(res.data.data, '时间')
							//初始化store中的时间
							for(let i = 0; i < res.data.data[0].deliveryList.length; i++) {
								if(res.data.data[0].deliveryList[i].valid == 1) {
									this.setTimeNormal(res.data.data[0].deliveryList[i]);
									this.setOrderFlag(true);
									return
								}
							}
						}
					} else if(type === 1) {
						this.bigTimeList = res.data.data;
						//初始化store中的时间
						if(res.data.data[0]) {
							for(let i = 0; i < res.data.data[0].deliveryList.length; i++) {
								if(res.data.data[0].deliveryList[i].valid == 1) {
									this.setTimeBig(res.data.data[0].deliveryList[i]);
									this.setOrderFlag(true);
									return
								}
							}
						}
					}
				})
			},
			//获取起送额
			getmoneySend() {
				let config = {
					url: window.api.trade_host + "/delivery_config/delivery/" + localStorage.getItem('storeCode'),
					method: 'GET',
					headers: {
						'sessionId': this.sessionId
					},
				};
				axios(config).then((res) => {
					this.sendMoney = res.data.data[0];
				})
			},
			//获取起配费用
			getMinSendM() {
				for(let i = 0; i < this.sendMoney.length; i++) {
					if(this.sendMoney[i].deliveryType === 0) {
						this.minNormalMoney = this.sendMoney[i].startingAtAmount;
						this.normalM = this.sendMoney[i].deliveryFees;
					} else if(this.sendMoney[i].deliveryType === 1) {
						this.minBigMoney = this.sendMoney[i].startingAtAmount;
						this.bigM = this.sendMoney[i].deliveryFees;
					}
				}
				console.log(this.minNormalMoney, this.normalM, this.minBigMoney, this.bigM);
			},

			//判断是否需要加运费
			checkeMoneySend() {
				if(this.listNormal.length > 0) {
					if(this.normalMoney < this.minNormalMoney) {
						console.log(this.minNormalMoney, '显示金额3');
						//获取总金额
						let m = Number(this.normalM);
						this.money += m;

						//存运费信息
						let obj = {};
						this.normalMFlag = true;
						obj.normalM = this.normalM;
						obj.normalMFlag = this.normalMFlag;
						this.setNormalM(obj);
					}
				}
				if(this.bigList.length > 0) {
					if(this.bigMoney < this.minBigMoney) {
						//获取总金额
						let m = Number(this.bigM);
						this.money += m;
						//存运费信息
						let obj = {};
						this.bigMFlag = true;
						obj.bigM = this.bigM;
						obj.bigMFlag = this.bigMFlag;
						this.setBigM(obj);
					}
				}
				this.getFreightM(); //用于展示的运费
			},
			getFreightM() {
				if(this.normalMFlag === true) {
					this.freightM += this.normalM;
				}
				if(this.bigMFlag === true) {
					this.freightM += this.bigM;
				}
			},
			//获取积分接口
			queryMyPoints() {
				let config = {
					url: window.api.customer_host + '/customer/getCustomer',
					method: 'GET',
					headers: {
						'sessionId': localStorage.getItem('sessionId'),
					},
				};
				axios(config).then((res) => {
					this.myPointsdata = res.data.data[0]
					this.flagtoken = false
					MessageBox('兑换成功！', '我的可用积分：' + (this.myPointsdata.remainingscore || 0)).then(() => {
						this.$router.push({
							path: 'integralBuyRecord'
						})
					})
				})
			},

			/*//判断是否展示发票入口
			supportInvoice() {
				this.supportInvoiceFlag = this.getConfigParams.supportInvoice;
			},
			innitFpData() {
				let url = window.api.service_host + '/mallconfig/selectInvoice';
				let config = {
					url: url,
					method: 'GET',
					headers: {
						'sessionId': this.sessionId
					},
				};
				axios(config).then((res) => {
					var str = ''; // 用于存放发票内容
					if(res.data.returnCode === 1) {
						var fpInfo = res.data.data[0];
						this.supportInvoiceFlag = res.data.data[0].supportInvoice;
						this.setFpInfo(fpInfo);
					}
				})
			},
			// 去发票页面
			toFp() {
				this.$router.push("orderfpInfo")
			},
			//获取发票参数
			getFpParams() {
				var newObj = {};
				let obj = this.getFpObj;
				if(!obj) {
					return;
				}
				if(obj.invoiceTitle == "单位") {
					newObj.invoiceType = obj.invoiceTypeCode; //类型
					newObj.invoiceHead = obj.invoiceTitle; // 抬头
					newObj.taxpayerNo = obj.taxpayerNo; // 税号
					newObj.companyName = obj.companyName; // 公司名字
					newObj.invoiceContent = obj.content; //发票内容
				} else if(obj.invoiceTitle == "个人") {
					newObj.invoiceType = obj.invoiceTypeCode; //类型
					newObj.invoiceHead = obj.invoiceTitle; // 抬头
					newObj.invoiceContent = obj.content; //发票内容
				}
				return newObj;
			},*/
			//获取 门店配送范围
			getRange() {
				var storeNow = this.getStoreNow;
				console.log(storeNow, '当前门店');
				var range1 = storeNow.deliveryRangeCode.match(/\d+/g);
				var range2 = storeNow.deliveryRangeName.match(/\d+/g);
				if(range1 != null) {
					this.storeRange = Number(range1[0]) * 1000;
				} else if(range2 != null) {
					this.storeRange = Number(range2[0]) * 1000;
				}
			},
			//将提交订单的地址  isNew置为 0
			setAddressIsNew(item) {
				let params = {
					type: "UPDATE",
					userid: item.userid,
					addressid: item.addressid,
					enterprisecode: window.api.enterpriseCode
				}
				var sessionId = localStorage.getItem('sessionId');
				let config = {
					url: window.api.customer_host + '/address',
					method: 'POST',
					data: params,
					headers: {
						'sessionId': sessionId,
						'Content-Type': 'application/json',
						'Accept': 'application/json'
					},
				}
				axios(config).then((res) => {
					console.log(res);
				})
			},
			//弹出选择配送时间让用户确认，用户不点击确定就一直弹出 选择时间的弹出框
			makeSureTime() {
				let flag = this.$refs.nomalTimeshow.chooseFlag;
				let flagXiaDan = false;
				if(!flag) {
					this.$refs.nomalTimeshow.showPop();
				} else {
					flagXiaDan = true;
				}
				return flagXiaDan;
			},
			//校验门店是否在配送范围内
			checkStoreRange() {
				var that = this;
				var myTimer = setTimeout(function() {
					//console.log('定时器')
					that.clickFlag = true;
				}, 5000)
				let payAddressFlag = this.getToPayAddress(); //获取用户收货地址
				if(!payAddressFlag) {
					return;
				}
				if(!this.sessionId) {
					this.$router.push('login');
				}
				if(!this.address || !this.address.addressid || this.address.addressid == -1) {
					this.$router.push({
						name: 'address',
						query: {
							pagepath: 'ConfirmOrderIntegral'
						}
					})
					return
				}

				// 判断配送时间接口是否已返回数据 并且有可用的配送时间 没返回就禁止下单
				if(!this.getOrderFlag) {
					Toast({
						message: '暂无可配送时间',
						duration: 1000,
						type: 'fail'
					});
					return;
				}
				let flagXiaDan = this.makeSureTime();
				if(!flagXiaDan) {
					return
				}
				console.log(this.clickFlag, '防止多次点击')
				//防止多次点击下单
				if(!this.clickFlag) {
					return;
				}
				this.clickFlag = false; // 点击后置为禁用状态
				var url = window.api.customer_host + "/address/getTMS";
				var params = {
					longitudeandlatitude: this.address.positionlng + ',' + this.address.positionlat
				}
				var config = {
					url: url,
					method: "GET",
					params
				}
				axios(config).then((res) => {
					console.log(res.data.returnCode, '校验配送地址');
					if(res.data.returnCode == 0) {
						Toast({
							message: '该地址不在配送范围内',
							duration: 1000,
							type: 'fail'
						});

						this.clickFlag = true; //接口返回  解除点击禁用

					} else if(res.data.returnCode == 1) {
						//如果地址存在  将该地址推送到首页和选择地址页
						this.setAddressIsNew(this.address);
						localStorage.setItem('locateIn', JSON.stringify(this.address));
						this.$store.dispatch('qxz/updateLocation', this.address);
						var latticeName = res.data.data[0].latticename;
						this.sendOrder(latticeName);
					}
				})
			},
			//生成订单
			async sendOrder(latticeName) {
				// 判断获取金额信息接口是否已返回数据  没返回就禁止下单
				var orderDeliveryTms = [];
				var norObj = {};
				var bigObj = {};
				var norMalTime = this.getTimeNormal;
				var bigTime = this.getTimeBig;
				if(norMalTime &&  this.maxTimeNormal &&  this.maxTimeNormal.length) {
					norObj.expectedTmStart = norMalTime.startPeriodTm;
					norObj.expectedTmEnd = norMalTime.endPeriodTm;
					norObj.showStartTm = norMalTime.startBookTm;
					norObj.showEndTm = norMalTime.endBookTm;
					norObj.goodsDeliveryType = 0;
					norObj.maxMachineTm = this.maxTimeNormal[1];
				}
				if(bigTime && this.maxTimeBig && this.maxTimeBig.length) {
					bigObj.expectedTmStart = bigTime.startPeriodTm;
					bigObj.expectedTmEnd = bigTime.endPeriodTm;
					bigObj.showStartTm = bigTime.startBookTm;
					bigObj.showEndTm = bigTime.endBookTm;
					bigObj.goodsDeliveryType = 1;
					bigObj.maxMachineTm = this.maxTimeBig[1];
				}
				if(this.checkedCartListNormal.length != 0) {
					orderDeliveryTms.push(norObj);
				}
				if(this.checkedCartListBig.length != 0) {
					orderDeliveryTms.push(bigObj);
				}
				console.log('收货地址信息');
				if(this.normalTimeList) {
					if(this.checkedCartListNormal.length > 0) {
						console.log(123)
						if(this.normalTimeList.length == 0 || this.normalTimeList[0].deliveryList.length == 0) {
							Toast({
								message: '暂无可配送时间',
								duration: 1000,
								type: 'fail'
							});
							return
						}
					}
				}
				if(this.bigTimeList) {
					if(this.checkedCartListBig.length > 0) {
						if(this.bigTimeList.length == 0 || this.bigTimeList[0].deliveryList.length == 0) {
							Toast({
								message: '暂无可配送时间',
								duration: 1000,
								type: 'fail'
							});
							return
						}
						console.log('暂无可配送时间')
					}
				}
				//获取对象的length
				if(!Object.getOwnPropertyNames(orderDeliveryTms[0]).length) {
					Toast({
						message: '请选择配送时间',
						duration: 1000,
						type: 'fail'
					});
					return
				}
				//校验配送方式
				if(!this.getDeliveryType) {
					Toast({
						message: '未获取到配送方式',
						duration: 1000,
						type: 'fail'
					});
					return
				}
				let electronicInvoice = {
					invoicesTitleId: this.$store.state.hzh.getBillInfor,
					invoiceContext: this.$store.state.hzh.BillContent
				}
				let params = {
					addressId: this.address.addressid, //收货地址
					deliveryType: this.getDeliveryType, //配送方式
					storeCode: localStorage.getItem('storeCode'), //调试用的 '5555555'  localStorage.getItem('storeId')   3df87595-762d-414e-be0f-6b6d8361f5d2  73ece0ae-ba0e-4501-b993-d727b9ae25c2
					orderDeliveryTms, //获取配送时间
					latticeName: latticeName, // wms网格  测试需要传该参数   预发布和生产不能传该参数
					integralGoodsRid: this.getconfigGoodsdata.rid,
					goodsCode: this.getconfigGoodsdata.goodscode,
					goodsNum: this.getconfigGoodsdata.goodsNum,
				};
				params.deliveryAddress = this.getAddressDetail; //this.address.address
				params.token = this.getNewToken; // 传token用于后台识别
				if(this.$store.state.hzh.getBillInfor.length != 0) {
					params.electronicInvoice = electronicInvoice; //发票信息提交
				}
				/*if(Object.keys(this.getFpObj).length) {
					var fpParams = this.getFpParams(); // 获取发票参数
				}
				if(fpParams) {
					params.orderInvoice = fpParams;
				}*/

				let config = {
					url: window.api.trade_host + '/integralOrder/insertCommonGoodsOrder',
					method: 'POST',
					data: params,
					headers: {
						'sessionId': localStorage.getItem('sessionId'),
						'Content-Type': 'application/json',
						'Accept': 'application/json'
					},
				}
				if(this.address && orderDeliveryTms.length > 0) {
					try {
						let data = await axios(config);
						this.flagtoken = true
						console.log(params, '下单请求参数信息')
						this.clickFlag = true; //接口返回  解除点击禁用
						console.log(data, '返回参数')
						if(data.data.returnCode == 1) {
							this.setconfigGoodsdata({})
							this.setconfigtokenNew(0)
							this.queryMyPoints()
						} else if(data.data.returnCode == 4) {
							this.flagtoken = false
							Toast({
								message: data.data.msg,
								duration: 3000,
								type: "fail"
							})
							setTimeout(() => {
								window.history.go(-2);
							}, 2000)
						} else {
							this.flagtoken = false
							this.getNewToken = data.data.data[0]
							Toast({
								message: data.data.msg,
								duration: 2000,
								type: 'fail'
							});
						}
					} catch(err) {
						console.log(err, '错误信息7777777777777777777777')
						this.clickFlag = true; //接口返回  解除点击禁用
						Toast({
							message: '生成订单失败',
							duration: 1000,
							type: 'fail'
						});
					}
				}
			},

		},
		created() {
			if(!this.sessionId) {
				this.$router.push('login');
			}
			this.getAddress();
		},
		mounted() {
			if(this.checkPayBack()) return;
			this.appendToPay();
			this.cartList();
			this.getGoodsdata();
			this.getmoneySend();
		},
		watch: {
			getToken(newVal, oldVal) {
				console.log(newVal);
			},
			sendMoney() {
				this.getMinSendM();
			},
		},
		beforeDestroy() {
			this.clickFlag = true; //接口返回  解除点击禁用
			this.setOrderFlag(false); // 将提交按钮设置为禁用状态
		},
		beforeRouteLeave(to, from, next) {
			//只能在父组件中触发    如果去购物车或者支付页面就把vuex中的信息删除
			if(to.name == "integralProDetail" || to.name == "integralBuyRecord" || to.name == "IntegralBuy") {
				this.setOrderFlag(false); //将禁止下单按钮点击
				let arr = [];
				this.setFpObj({}); // 清空发票
				this.setTicketList(arr); //清空优惠券
				this.setUseGiftCard(false); // 清空钱包选择
				this.setMynode(""); // 清空留言

				this.setDateNormal(null); // 清空配送日期
				this.setDateBig(null); // 清空配送日期
				this.setTimeNormal({}); // 清空配送时间
				this.setTimeBig({}); // 清空配送时间

				this.setTimeSaveObj({});
			}
			console.log(to.name, '去到哪个页面');
			next();
		},
	}
</script>

<style scoped="scoped">
	.content {
		flex: 1;
		overflow-y: auto;
		position: relative;
		top: -1px;
	}
	
	.zxBottomBtn {
		height: 3rem;
		width: 100%;
		display: flex;
		justify-content: flex-end;
		flex-direction: row;
		align-items: center;
		background: #fff;
	}
	
	.zxSendOrderPrice {
		font-size: 0.7rem;
		margin-right: 0.75rem;
	}
	
	.zxSendOrder {
		height: 3rem;
		font-size: 1rem;
		text-align: center;
		line-height: 3rem;
		background: #EF5423;
		padding: 0 1rem;
		color: #fff;
	}
	
	.box {
		width: 100%;
		height: 100%;
		display: flex;
		justify-content: space-between;
		flex-direction: column;
	}
	
	.confrimOrderTopBar {
		width: 100%;
		height: 3.15rem;
		background: #38b035;
		position: relative;
		top: 0;
		left: 0;
		z-index: 0;
	}
	
	.confrimOrderTimeAddressBox {
		background-color: #fff;
		width: 93%;
		border-radius: 0.2rem;
		margin: 0 auto;
		min-height: 5.1rem;
	}
	
	.confrimOrderAddressBox {
		margin-right: 0.75rem;
		margin-left: 0.75rem;
		border-bottom: 1px solid #e8e8e8;
		height: 3.1rem;
	}
	
	.confrimOrderTimeBox {
		margin-right: 0.75rem;
		margin-left: 0.75rem;
	}
</style>